//
// Created by Administrator on 2021/11/8.
// May Saint Diana bless you!
//
#include <vector>
#include <iostream>
#include <string>


using namespace std;

class Solution {
public:
    string getHint(string secret, string guess) {
        unsigned int n = secret.size();
        vector<int> secretCounter(10, 0);
        vector<int> guessCounter(10, 0);
        int x = 0, y = 0;
        for (int i = 0; i < n; ++i) {
            if (secret[i] == guess[i])
                ++x;
            else {
                ++secretCounter[secret[i] - '0'];
                ++guessCounter[guess[i] - '0'];
            }
        }
        for (int i = 0; i < 10; ++i) {
            y += min(guessCounter[i], secretCounter[i]);
        }
        return to_string(x) + "A" + to_string(y) + "B";
    }
};

int main() {
    Solution solution;
    cout << solution.getHint("1807", "7810") << endl;
    return 0;
}
